package com.training.admin.entity.search;

import java.util.Map;

import com.demo2do.core.persistence.support.QueryFilter;
import com.demo2do.core.persistence.support.QueryOrder;

/**
 *
 * @author Rockett
 *
 */
public class ProjectCourseReportSearch extends ReportSearch {

    
	/** proje名称 */
    private String projectName;
    /** course名称 */
    private String courseName;
    /** 是否标准课程 */
    private String property;
    /** 课程类型 */
    private String type;
    /** 事业部*/
    private Long departmentId;
   


    private QueryFilter filter;
    
    private QueryOrder order;

    
    /**
     * The default constructor
     */
    public ProjectCourseReportSearch() {
        order = new QueryOrder("p.projectPhase.project.name", "asc");
    }
    /* (non-Javadoc)
     * @see com.demo2do.core.persistence.support.QueryBuilder#getPreparedFilter(boolean)
     */
    public QueryFilter getPreparedFilter(boolean refresh) {
    	
        if (filter == null || refresh) {
        	
            filter = new QueryFilter().addLike("p.projectPhase.project.name", projectName)
									.addLike("p.course.name", courseName)
									.addLike("p.course.type", type)
									.addEquals("p.projectPhase.project.department","id", departmentId)
                                    .addLike("p.course.property", property);
         }
        
        return filter;
        
    }
    
 
    
    /*
     * (non-Javadoc)
     * @see com.demo2do.core.persistence.support.QueryBuilder#buildSentenceTemplate()
     */
    public String buildSentenceTemplate() {
        String sentence = "FROM ProjectPhaseCourse as p where p.disabled = false " + getPreparedFilter(false).clauseSentence() + order.sentence();
        return sentence;
    }

    /*
     * (non-Javadoc)
     * @see com.demo2do.core.persistence.support.QueryBuilder#buildParameters()
     */
    public Map<String, Object> buildParameters() {
        return getPreparedFilter(false).parameters();
    }
    

    /**
     * 
     * @return
     */
    public QueryFilter getFilter(){
        return getPreparedFilter(false);
    }
	/**
	 * @return the order
	 */
	public QueryOrder getOrder() {
		return order;
	}
	/**
	 * @return the projectName
	 */
	public String getProjectName() {
		return projectName;
	}
	/**
	 * @param projectName the projectName to set
	 */
	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}
	/**
	 * @return the courseName
	 */
	public String getCourseName() {
		return courseName;
	}
	/**
	 * @param courseName the courseName to set
	 */
	public void setCourseName(String courseName) {
		this.courseName = courseName;
	}
	/**
	 * @return the property
	 */
	public String getProperty() {
		return property;
	}
	/**
	 * @param property the property to set
	 */
	public void setProperty(String property) {
		this.property = property;
	}
	/**
	 * @return the type
	 */
	public String getType() {
		return type;
	}
	/**
	 * @param type the type to set
	 */
	public void setType(String type) {
		this.type = type;
	}
	/**
	 * @return the departmentId
	 */
	public Long getDepartmentId() {
		return departmentId;
	}
	/**
	 * @param departmentId the departmentId to set
	 */
	public void setDepartmentId(Long departmentId) {
		this.departmentId = departmentId;
	}



}
